package br.com.rookgraph;

import static br.com.rookgraph.GraphPopulator.edger1;
import static br.com.rookgraph.GraphPopulator.edger2;
import static br.com.rookgraph.GraphPopulator.edger3;
import static br.com.rookgraph.GraphPopulator.edger4;
import static br.com.rookgraph.GraphPopulator.edger5;
import static br.com.rookgraph.GraphPopulator.edger6;
import static br.com.rookgraph.GraphPopulator.getFullGraph;

import org.junit.Assert;
import org.junit.Test;

public class GraphTestGetTree {
	
	@Test
	public void rootOne(){
		Graph graph = getFullGraph();
		Graph tree  = graph.getTree(new Graph(6), 1);
		
		Assert.assertTrue(tree.hasEdge(edger1));
		Assert.assertTrue(tree.hasEdge(edger2));
		Assert.assertTrue(tree.hasEdge(edger4));
		Assert.assertTrue(tree.hasEdge(edger5));
		Assert.assertTrue(tree.hasEdge(edger6));

		Assert.assertFalse(tree.hasEdge(edger3));
	}
	
	@Test
	public void rootTwo(){
		Graph graph = getFullGraph();
		Graph tree  = graph.getTree(new Graph(6), 2);
		
		Assert.assertTrue(tree.hasEdge(edger1));
		Assert.assertTrue(tree.hasEdge(edger3));
		Assert.assertTrue(tree.hasEdge(edger4));
		Assert.assertTrue(tree.hasEdge(edger5));
		Assert.assertTrue(tree.hasEdge(edger6));
		
		Assert.assertFalse(tree.hasEdge(edger2));
	}

	@Test
	public void rootThree(){
		Graph graph = getFullGraph();
		Graph tree  = graph.getTree(new Graph(6), 3);
		
		Assert.assertTrue(tree.hasEdge(edger1));
		Assert.assertTrue(tree.hasEdge(edger3));
		Assert.assertTrue(tree.hasEdge(edger4));
		Assert.assertTrue(tree.hasEdge(edger5));
		Assert.assertTrue(tree.hasEdge(edger6));
		
		Assert.assertFalse(tree.hasEdge(edger2));
	}

	@Test
	public void rootFour(){
		Graph graph = getFullGraph();
		Graph tree  = graph.getTree(new Graph(6), 4);
		
		Assert.assertTrue(tree.hasEdge(edger1));
		Assert.assertTrue(tree.hasEdge(edger3));
		Assert.assertTrue(tree.hasEdge(edger4));
		Assert.assertTrue(tree.hasEdge(edger5));
		Assert.assertTrue(tree.hasEdge(edger6));

		Assert.assertFalse(tree.hasEdge(edger2));
	}
	
	@Test
	public void rootFive(){
		Graph graph = getFullGraph();
		Graph tree  = graph.getTree(new Graph(6), 5);
		
		Assert.assertTrue(tree.hasEdge(edger1));
		Assert.assertTrue(tree.hasEdge(edger2));
		Assert.assertTrue(tree.hasEdge(edger4));
		Assert.assertTrue(tree.hasEdge(edger5));
		Assert.assertTrue(tree.hasEdge(edger6));
		
		Assert.assertFalse(tree.hasEdge(edger3));
	}

	@Test
	public void rootSix(){
		Graph graph = getFullGraph();
		Graph tree  = graph.getTree(new Graph(6), 6);
		
		Assert.assertTrue(tree.hasEdge(edger1));
		Assert.assertTrue(tree.hasEdge(edger2));
		Assert.assertTrue(tree.hasEdge(edger4));
		Assert.assertTrue(tree.hasEdge(edger5));
		Assert.assertTrue(tree.hasEdge(edger6));

		Assert.assertFalse(tree.hasEdge(edger3));
	}

}
